home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gnugo1_1.lha / gnugo / exambord.c < prev    next >
C/C++ Source or Header  |  1989-03-07  |  2KB  |  101 lines

  1. /*
  2.                 GNU GO - the game of Go (Wei-Chi)
  3.                 Version 1.1   last revised 3-1-89
  4.            Copyright (C) Free Software Foundation, Inc.
  5.                       written by Man L. Li
  6.                       modified by Wayne Iba
  7.                     documented by Bob Webber
  8. */
  9. /*
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation - version 1.
  13.  
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. GNU General Public License in file COPYING for more details.
  18.  
  19. You should have received a copy of the GNU General Public License
  20. along with this program; if not, write to the Free Software
  21. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23. Please report any bug/fix, modification, suggestion to
  24.  
  25. mail address:   Man L. Li
  26.                 Dept. of Computer Science
  27.                 University of Houston
  28.                 4800 Calhoun Road
  29.                 Houston, TX 77004
  30.  
  31. e-mail address: manli@cs.uh.edu         (Internet)
  32.                 coscgbn@uhvax1.bitnet   (BITNET)
  33.                 70070,404               (CompuServe)
  34. */
  35.  
  36. #include <stdio.h>
  37.  
  38. #define EMPTY 0
  39.  
  40. extern unsigned char p[19][19], l[19][19];
  41. extern int mymove;
  42. extern int mik, mjk, uik, ujk, mk, uk;  /* piece captured */
  43.  
  44. examboard(color)
  45. /* examine pieces */
  46. int color;
  47.   {
  48.    int i, j, n;
  49.  
  50.  
  51. /* find liberty of each piece */
  52.    eval(color);
  53.  
  54. /* initialize piece captured */
  55.    if (color == mymove)
  56.      {
  57.       mik = -1;
  58.       mjk = -1;
  59.     }
  60.    else
  61.      {
  62.       uik = -1;
  63.       ujk = -1;
  64.     }
  65.    n = 0; /* The number of captures this move for Ko purposes */
  66.  
  67. /* remove all piece of zero liberty */
  68.    for (i = 0; i < 19; i++)
  69.      for (j = 0; j < 19; j++)
  70.        if ((p[i][j] == color) && (l[i][j] == 0))
  71.      {
  72.       p[i][j] = EMPTY;
  73. /* record piece captured */
  74.       if (color == mymove)
  75.         {
  76.          mik = i;
  77.          mjk = j;
  78.          ++mk;
  79.        }
  80.       else
  81.         {
  82.          uik = i;
  83.          ujk = j;
  84.          ++uk;
  85.        }
  86.       ++n;  /* increment number of captures on this move */
  87.     }
  88. /* reset to -1 if more than one stone captured since  no Ko possible */
  89.    if (color == mymove && n > 1)
  90.      {
  91.        mik = -1;   
  92.        mjk = -1;
  93.      }
  94.    else if ( n > 1 )
  95.      {
  96.        uik = -1;
  97.        ujk = -1;
  98.      }
  99. }  /* end examboard */
  100.  
  101.